#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Last Update:

'''docstring
'''

__revision__ = '0.1'
__author__ = 'lxd'

import re
def get_proxies(data):
    '''获取中国代理地址列表 'http://www.5uproxy.net/http_fast.html'
    '''
    reg = r'<td>(?P<ip>[^<>].*?)</td>[\s\S]*?<td width="60">(?P<port>\d+)</td>[\s\S]*?<td width="60">(.*?)</td>'
    m = re.compile(reg, re.IGNORECASE).findall(data) 
    proxies = ['%s:%s' % (p[0], p[1]) for p in m if p[2] == 'CN']
    return proxies

def get_local_ip(data):
    '''查看本机IP 'http://www.ip138.com/ip2city.asp'
    '''
    reg = r'\[(([12][0-9][0-9]|[1-9][0-9]|[1-9])\.){3,3}([12][0-9][0-9]|[1-9][0-9]|[1-9])\]' 
    m = re.compile(reg, re.IGNORECASE).search(data)
    if m: return m.group()[1:-1]

